package com.woniu.filter;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.servlet.Filter;

/**
 * 注册系统中所有的过滤器用的
 */
@Configuration
public class WebFilter {

    @Autowired
    private LoginFilter loginFilter;

    @Bean
    public FilterRegistrationBean<LoginFilter> loginFilterBean(){
        FilterRegistrationBean frb = new FilterRegistrationBean<>();
        frb.setFilter(loginFilter);
        frb.addUrlPatterns("/*");
        frb.setOrder(1);//接收一个int 数值，数值越小，越先执行

        return frb;
    }

}
